/*
 * Copyright (c) 2009 Team TypeZero
 *
 * This file is part of ZebBowling
 *
 * ZebBowling is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ZebBowling is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZebBowling. If not, see <http://www.gnu.org/licenses/>.
 **/

package org.zebbowling.world;

/**
 * This class represents the score of a {@linkplain BowlingPlayer} according to
 * general bowling scoring.
 *
 * @author Mark Vismonte
 */
public class BowlingScore extends Object
    {
    //current score
    private int score;
    //1 for spare, 2 for strike
    private int nextCounter;

    /**
     * Creates a new {@code BowlingScore}
     *
     * @param score The initial score
     * @param nextCounter The initial {@code nextCounter}.
     */
    public BowlingScore(int score, int nextCounter)
        {
        super();
        this.score = score;
        this.nextCounter = nextCounter;
        }

    /**
     * Adds the specified score to this score.
     *
     * @param score The score to add.
     */
    public void addToScore(int score)
        {
        this.score = nextCounter-- > 0? (this.score + score): this.score;
        }

    /**
     * Returns {@code boolean} indicating if scoring is done.
     *
     * @return <tt>true</tt> if scoring is done else <tt>false</tt>.
     */
    public boolean scoreFinish()
        {
        return nextCounter - 1 > 0;
        }

    /**
     * Returns the current score.
     *
     * @return The current score.
     */
    public int getScore()
        {
        return score;
        }

    public String toString()
        {
        return "Current Score: " + getScore() + " Additions Left: " + nextCounter;
        }
    }
